Skip to content

MvP-4345 series#421

Open
ctnguyen wants to merge 8 commits intobsv-blockchain:mainfrom
ctnguyen:Feature/MvP-4345_series
Open

MvP-4345 series#421
ctnguyen wants to merge 8 commits intobsv-blockchain:mainfrom
ctnguyen:Feature/MvP-4345_series

Conversation

@ctnguyen
Copy link
Copy Markdown
Collaborator

This is the group series of PR : MvP-4434 MvP4441 MvP 4443, all items inside the larger issue https://github.com/bitcoin-sv/teranode/issues/4345. Each commit resolve one issue item

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

🤖 Claude Code Review

Status: Complete


This PR implements a significant refactor of the validator service, properly separating consensus rules (always enforced) from policy rules (mempool-only). The changes align teranode with the C++ bitcoin-sv implementation.

Key Changes:

  • Consensus sigops check: New checkConsensusSigops() enforces 20,000 sigops limit pre-Genesis (always runs)
  • Policy sigops check: Enhanced sigOpsCheck() with full CScriptNum parsing for accurate multisig counting (mempool-only)
  • Transaction size checks: Now properly separated into consensus (1MB pre-Genesis, 1GB post-Genesis) and policy limits
  • P2SH output ban: Post-Genesis P2SH outputs now rejected as consensus rule (not just policy)
  • Null prevout check: New checkPrevOutputs() prevents invalid input references
  • Consolidation logic: Enhanced with proper dust donation detection and extensive logging
  • Dust checking removed: Previous dust checks in checkOutputs() have been removed (correct for consensus rules)
  • MaxCoinsViewCacheSize: New policy setting to prevent DoS via large input script accumulation

Test Coverage:

  • New test files: TxValidator_sigops_test.go, TxValidator_p2sh_test.go, TxValidator_prevout_test.go
  • Tests verify consensus vs policy separation
  • Comprehensive edge case coverage for sigops counting

No issues found - the implementation appears correct and well-documented. The code properly implements C++ bitcoin-sv validation logic with clear comments referencing source file locations.

@ctnguyen ctnguyen force-pushed the Feature/MvP-4345_series branch 3 times, most recently from 358b2b2 to dff9237 Compare February 27, 2026 11:55
@ctnguyen ctnguyen force-pushed the Feature/MvP-4345_series branch from dff9237 to da383d1 Compare March 2, 2026 07:59
@ctnguyen ctnguyen force-pushed the Feature/MvP-4345_series branch from da383d1 to 23f4aab Compare March 31, 2026 11:02
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
72.6% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark Comparison Report

Baseline: main (unknown)

Current: PR-421 (0b9072d)

Summary

  • Regressions: 0
  • Improvements: 0
  • Unchanged: 151
  • Significance level: p < 0.05
All benchmark results (sec/op)
Benchmark Baseline Current Change p-value
_NewBlockFromBytes-4 1.395µ 1.440µ ~ 0.100
SplitSyncedParentMap_SetIfNotExists/256_buckets-4 61.77n 61.55n ~ 0.400
SplitSyncedParentMap_SetIfNotExists/16_buckets-4 61.61n 61.68n ~ 0.400
SplitSyncedParentMap_SetIfNotExists/1_bucket-4 61.65n 61.69n ~ 0.300
SplitSyncedParentMap_ConcurrentSetIfNotExists/256_buckets... 30.74n 30.47n ~ 1.000
SplitSyncedParentMap_ConcurrentSetIfNotExists/16_buckets_... 53.61n 52.66n ~ 0.200
SplitSyncedParentMap_ConcurrentSetIfNotExists/1_bucket_pa... 109.0n 107.6n ~ 0.700
MiningCandidate_Stringify_Short-4 267.9n 259.3n ~ 0.100
MiningCandidate_Stringify_Long-4 1.901µ 1.856µ ~ 0.200
MiningSolution_Stringify-4 955.4n 938.9n ~ 0.100
BlockInfo_MarshalJSON-4 1.757µ 1.764µ ~ 0.600
NewFromBytes-4 128.8n 158.7n ~ 0.700
Mine_EasyDifficulty-4 58.55µ 57.60µ ~ 0.100
Mine_WithAddress-4 4.744µ 5.036µ ~ 0.700
BlockAssembler_AddTx-4 0.02713n 0.02574n ~ 0.500
AddNode-4 11.10 11.08 ~ 0.700
AddNodeWithMap-4 11.25 10.75 ~ 0.400
DirectSubtreeAdd/4_per_subtree-4 62.64n 57.90n ~ 0.700
DirectSubtreeAdd/64_per_subtree-4 30.15n 30.25n ~ 0.700
DirectSubtreeAdd/256_per_subtree-4 28.87n 29.08n ~ 0.100
DirectSubtreeAdd/1024_per_subtree-4 27.86n 28.04n ~ 0.700
DirectSubtreeAdd/2048_per_subtree-4 27.46n 27.71n ~ 0.200
SubtreeProcessorAdd/4_per_subtree-4 297.9n 307.8n ~ 0.100
SubtreeProcessorAdd/64_per_subtree-4 296.0n 307.7n ~ 0.100
SubtreeProcessorAdd/256_per_subtree-4 297.7n 303.6n ~ 0.700
SubtreeProcessorAdd/1024_per_subtree-4 301.1n 305.5n ~ 0.100
SubtreeProcessorAdd/2048_per_subtree-4 302.1n 301.3n ~ 1.000
SubtreeProcessorRotate/4_per_subtree-4 303.7n 314.2n ~ 0.100
SubtreeProcessorRotate/64_per_subtree-4 301.4n 312.5n ~ 0.100
SubtreeProcessorRotate/256_per_subtree-4 302.3n 305.6n ~ 0.100
SubtreeProcessorRotate/1024_per_subtree-4 301.4n 306.8n ~ 0.100
SubtreeNodeAddOnly/4_per_subtree-4 63.17n 65.42n ~ 0.100
SubtreeNodeAddOnly/64_per_subtree-4 38.97n 39.30n ~ 0.700
SubtreeNodeAddOnly/256_per_subtree-4 38.08n 37.79n ~ 0.800
SubtreeNodeAddOnly/1024_per_subtree-4 36.91n 37.50n ~ 0.100
SubtreeCreationOnly/4_per_subtree-4 138.2n 142.9n ~ 0.200
SubtreeCreationOnly/64_per_subtree-4 618.9n 630.9n ~ 0.100
SubtreeCreationOnly/256_per_subtree-4 2.224µ 2.241µ ~ 0.700
SubtreeCreationOnly/1024_per_subtree-4 7.758µ 8.123µ ~ 0.100
SubtreeCreationOnly/2048_per_subtree-4 14.71µ 15.12µ ~ 0.200
SubtreeProcessorOverheadBreakdown/64_per_subtree-4 300.4n 305.7n ~ 0.100
SubtreeProcessorOverheadBreakdown/1024_per_subtree-4 299.3n 304.6n ~ 0.100
ParallelGetAndSetIfNotExists/1k_nodes-4 943.3µ 953.7µ ~ 0.100
ParallelGetAndSetIfNotExists/10k_nodes-4 1.906m 1.903m ~ 1.000
ParallelGetAndSetIfNotExists/50k_nodes-4 8.138m 8.235m ~ 0.400
ParallelGetAndSetIfNotExists/100k_nodes-4 15.93m 16.40m ~ 0.100
SequentialGetAndSetIfNotExists/1k_nodes-4 774.9µ 775.9µ ~ 0.700
SequentialGetAndSetIfNotExists/10k_nodes-4 3.062m 3.102m ~ 0.400
SequentialGetAndSetIfNotExists/50k_nodes-4 11.01m 11.13m ~ 0.100
SequentialGetAndSetIfNotExists/100k_nodes-4 20.91m 21.14m ~ 0.700
ProcessOwnBlockSubtreeNodesParallel/1k_nodes-4 997.7µ 984.2µ ~ 0.100
ProcessOwnBlockSubtreeNodesParallel/10k_nodes-4 4.684m 4.699m ~ 1.000
ProcessOwnBlockSubtreeNodesParallel/100k_nodes-4 19.09m 19.43m ~ 0.100
ProcessOwnBlockSubtreeNodesSequential/1k_nodes-4 811.7µ 806.7µ ~ 0.400
ProcessOwnBlockSubtreeNodesSequential/10k_nodes-4 6.117m 6.079m ~ 0.700
ProcessOwnBlockSubtreeNodesSequential/100k_nodes-4 40.51m 40.46m ~ 0.700
DiskTxMap_SetIfNotExists-4 4.156µ 4.374µ ~ 1.000
DiskTxMap_SetIfNotExists_Parallel-4 3.920µ 3.914µ ~ 1.000
DiskTxMap_ExistenceOnly-4 397.7n 467.1n ~ 0.700
Queue-4 211.9n 205.7n ~ 0.100
AtomicPointer-4 8.149n 8.129n ~ 0.100
ReorgOptimizations/DedupFilterPipeline/Old/10K-4 874.4µ 794.6µ ~ 0.100
ReorgOptimizations/DedupFilterPipeline/New/10K-4 816.3µ 746.8µ ~ 0.100
ReorgOptimizations/AllMarkFalse/Old/10K-4 133.7µ 114.6µ ~ 0.100
ReorgOptimizations/AllMarkFalse/New/10K-4 58.42µ 58.40µ ~ 1.000
ReorgOptimizations/HashSlicePool/Old/10K-4 77.85µ 73.17µ ~ 0.400
ReorgOptimizations/HashSlicePool/New/10K-4 11.80µ 11.78µ ~ 0.100
ReorgOptimizations/NodeFlags/Old/10K-4 5.703µ 6.387µ ~ 0.100
ReorgOptimizations/NodeFlags/New/10K-4 1.949µ 2.505µ ~ 0.100
ReorgOptimizations/DedupFilterPipeline/Old/100K-4 12.10m 13.71m ~ 0.100
ReorgOptimizations/DedupFilterPipeline/New/100K-4 11.79m 12.36m ~ 0.100
ReorgOptimizations/AllMarkFalse/Old/100K-4 1.222m 1.282m ~ 0.100
ReorgOptimizations/AllMarkFalse/New/100K-4 733.7µ 729.7µ ~ 0.700
ReorgOptimizations/HashSlicePool/Old/100K-4 602.8µ 609.0µ ~ 0.400
ReorgOptimizations/HashSlicePool/New/100K-4 309.5µ 318.5µ ~ 0.400
ReorgOptimizations/NodeFlags/Old/100K-4 56.22µ 57.25µ ~ 0.400
ReorgOptimizations/NodeFlags/New/100K-4 19.43µ 19.52µ ~ 0.100
TxMapSetIfNotExists-4 50.41n 49.59n ~ 0.700
TxMapSetIfNotExistsDuplicate-4 43.45n 43.37n ~ 0.200
ChannelSendReceive-4 674.0n 683.6n ~ 0.100
CalcBlockWork-4 521.6n 524.6n ~ 0.400
CalculateWork-4 701.5n 724.1n ~ 0.700
BuildBlockLocatorString_Helpers/Size_10-4 1.295µ 1.295µ ~ 0.800
BuildBlockLocatorString_Helpers/Size_100-4 12.44µ 12.44µ ~ 1.000
BuildBlockLocatorString_Helpers/Size_1000-4 122.8µ 147.4µ ~ 0.400
CatchupWithHeaderCache-4 104.3m 104.3m ~ 0.700
_BufferPoolAllocation/16KB-4 3.388µ 3.505µ ~ 0.700
_BufferPoolAllocation/32KB-4 8.080µ 7.868µ ~ 0.700
_BufferPoolAllocation/64KB-4 15.19µ 16.38µ ~ 0.100
_BufferPoolAllocation/128KB-4 28.91µ 28.24µ ~ 1.000
_BufferPoolAllocation/512KB-4 113.7µ 116.5µ ~ 0.700
_BufferPoolConcurrent/32KB-4 17.92µ 19.41µ ~ 0.100
_BufferPoolConcurrent/64KB-4 28.28µ 31.53µ ~ 0.100
_BufferPoolConcurrent/512KB-4 142.8µ 146.3µ ~ 0.700
_SubtreeDeserializationWithBufferSizes/16KB-4 647.6µ 716.0µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/32KB-4 644.6µ 720.8µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/64KB-4 645.3µ 711.2µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/128KB-4 643.0µ 717.1µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/512KB-4 653.0µ 738.2µ ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/16KB-4 35.50m 36.09m ~ 0.200
_SubtreeDataDeserializationWithBufferSizes/32KB-4 35.82m 35.73m ~ 1.000
_SubtreeDataDeserializationWithBufferSizes/64KB-4 35.92m 35.72m ~ 0.400
_SubtreeDataDeserializationWithBufferSizes/128KB-4 35.48m 35.88m ~ 1.000
_SubtreeDataDeserializationWithBufferSizes/512KB-4 35.73m 36.23m ~ 0.700
_PooledVsNonPooled/Pooled-4 739.1n 738.4n ~ 0.800
_PooledVsNonPooled/NonPooled-4 7.168µ 6.612µ ~ 0.100
_MemoryFootprint/Current_512KB_32concurrent-4 6.735µ 6.732µ ~ 1.000
_MemoryFootprint/Proposed_32KB_32concurrent-4 9.067µ 9.378µ ~ 0.100
_MemoryFootprint/Alternative_64KB_32concurrent-4 8.889µ 9.005µ ~ 0.200
_prepareTxsPerLevel-4 423.6m 443.4m ~ 0.100
_prepareTxsPerLevelOrdered-4 3.823m 3.731m ~ 0.400
_prepareTxsPerLevel_Comparison/Original-4 415.2m 431.7m ~ 0.100
_prepareTxsPerLevel_Comparison/Optimized-4 3.714m 3.891m ~ 0.100
SubtreeProcessor/100_tx_64_per_subtree-4 82.99m 83.35m ~ 1.000
SubtreeProcessor/500_tx_64_per_subtree-4 399.4m 402.0m ~ 0.400
SubtreeProcessor/500_tx_256_per_subtree-4 413.2m 417.8m ~ 0.100
SubtreeProcessor/1k_tx_64_per_subtree-4 794.3m 793.4m ~ 0.400
SubtreeProcessor/1k_tx_256_per_subtree-4 813.5m 813.8m ~ 0.700
StreamingProcessorPhases/FilterValidated/100_tx-4 2.822m 2.843m ~ 0.100
StreamingProcessorPhases/ClassifyProcess/100_tx-4 247.5µ 238.3µ ~ 0.700
StreamingProcessorPhases/FilterValidated/500_tx-4 13.73m 13.91m ~ 0.100
StreamingProcessorPhases/ClassifyProcess/500_tx-4 610.6µ 607.5µ ~ 1.000
StreamingProcessorPhases/FilterValidated/1k_tx-4 27.55m 27.19m ~ 0.700
StreamingProcessorPhases/ClassifyProcess/1k_tx-4 1.062m 1.076m ~ 0.200
SubtreeSizes/10k_tx_4_per_subtree-4 1.319m 1.333m ~ 1.000
SubtreeSizes/10k_tx_16_per_subtree-4 322.9µ 322.7µ ~ 1.000
SubtreeSizes/10k_tx_64_per_subtree-4 76.22µ 74.94µ ~ 0.100
SubtreeSizes/10k_tx_256_per_subtree-4 19.31µ 18.55µ ~ 0.100
SubtreeSizes/10k_tx_512_per_subtree-4 9.484µ 9.325µ ~ 0.100
SubtreeSizes/10k_tx_1024_per_subtree-4 4.697µ 4.608µ ~ 0.100
SubtreeSizes/10k_tx_2k_per_subtree-4 2.335µ 2.319µ ~ 0.100
BlockSizeScaling/10k_tx_64_per_subtree-4 73.93µ 74.25µ ~ 1.000
BlockSizeScaling/10k_tx_256_per_subtree-4 18.83µ 18.58µ ~ 0.700
BlockSizeScaling/10k_tx_1024_per_subtree-4 4.650µ 4.714µ ~ 0.300
BlockSizeScaling/50k_tx_64_per_subtree-4 392.7µ 395.4µ ~ 1.000
BlockSizeScaling/50k_tx_256_per_subtree-4 93.67µ 92.91µ ~ 0.700
BlockSizeScaling/50k_tx_1024_per_subtree-4 23.26µ 22.95µ ~ 0.700
SubtreeAllocations/small_subtrees_exists_check-4 161.1µ 158.4µ ~ 0.400
SubtreeAllocations/small_subtrees_data_fetch-4 166.2µ 166.6µ ~ 1.000
SubtreeAllocations/small_subtrees_full_validation-4 324.4µ 321.9µ ~ 0.100
SubtreeAllocations/medium_subtrees_exists_check-4 9.384µ 8.988µ ~ 0.100
SubtreeAllocations/medium_subtrees_data_fetch-4 9.613µ 9.684µ ~ 0.400
SubtreeAllocations/medium_subtrees_full_validation-4 18.84µ 18.60µ ~ 0.100
SubtreeAllocations/large_subtrees_exists_check-4 2.248µ 2.170µ ~ 0.100
SubtreeAllocations/large_subtrees_data_fetch-4 2.312µ 2.352µ ~ 0.200
SubtreeAllocations/large_subtrees_full_validation-4 4.695µ 4.614µ ~ 0.100
GetUtxoHashes-4 269.6n 272.7n ~ 0.300
GetUtxoHashes_ManyOutputs-4 52.17µ 45.38µ ~ 0.100
_NewMetaDataFromBytes-4 247.8n 230.7n ~ 0.100
_Bytes-4 662.7n 620.2n ~ 0.100
_MetaBytes-4 623.2n 572.8n ~ 0.100

Threshold: >10% with p < 0.05 | Generated: 2026-03-31 11:19 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant